/*
 * ShopCategoryGoodsActivity.java
 * business
 *
 * Created by ChenTao on 2016/10/25.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.shopdetail.categorygoods;

import android.app.Activity;
import android.content.Intent;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.data.model.ShopModel;
import com.yidiandao.business.utils.ActivityUtils;

/**
 * 店铺分类详情Activity.
 */
public class ShopCategoryGoodsActivity extends BaseActivity {

    private ShopCategoryGoodsFragment mCategoryGoodsFragment;

    public static void actionStart(
            Activity activity, String categoryName, String supplierId, String categoryId) {
        Intent intent = new Intent(activity, ShopCategoryGoodsActivity.class);
        intent.putExtra(Intents.EXTRA_CATEGORY_NAME, categoryName);
        intent.putExtra(Intents.EXTRA_SUPPLIER_ID, supplierId);
        intent.putExtra(Intents.EXTRA_CATEGORY_ID, categoryId);
        activity.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        mCategoryGoodsFragment = (ShopCategoryGoodsFragment) getSupportFragmentManager().findFragmentById(R.id.container_shop_category_goods);

        if (mCategoryGoodsFragment == null) {
            mCategoryGoodsFragment = ShopCategoryGoodsFragment.getInstance(getIntent().getExtras());
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), mCategoryGoodsFragment, R.id.container_shop_category_goods);
        }
    }

    @Override
    protected void initPresenter() {
        new ShopCategoryGoodsPresenter(mCategoryGoodsFragment, new ShopModel());
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_shop_category_goods;
    }
}
